// import { random } from 'core-js/fn/number'
import Mock, { Random } from 'mockjs'

// 登录时返回的数据
const login = {
  token: Random.string(18),
  id: Random.string('number', 1),
  userName: '',
  passWord: ''

}
const patients = {
  'list|1-10': [{
    // 属性 id 是一个自增数，起始值为 1，每次增 1
    id: '@increment(100)',
    recordTime: Random.now(),
    // courierCompany: '@name',
    sendNumber: /[1-9]{1}[0-9]{1,3}/,
    accessNumber: /[1-9]{1}[0-9]{1,3}/,
    county: '@county',
    siteName: '@name'
  }
  ]
}

const user = {
  list: [
    {
      // 属性 id 是一个自增数，起始值为 1，每次增 1
      id: Random.id(),
      realname: '@cname',
      phone: /^1[3-8][0-9]{9}$/,
      password: '@name',
      clientName: Random.id(),
      status: 1,
      auth: 1
    },
    {
      // 属性 id 是一个自增数，起始值为 1，每次增 1
      id: Random.id(),
      realname: '@cname',
      phone: /^1[3-8][0-9]{9}$/,
      password: '@name',
      clientName: Random.id(),
      status: 1,
      auth: 1
    },
    {
      // 属性 id 是一个自增数，起始值为 1，每次增 1
      id: Random.id(),
      realname: '@cname',
      phone: /^1[3-8][0-9]{9}$/,
      password: '@name',
      clientName: Random.id(),
      status: 1,
      auth: 1
    }
  ]
}
var newList = user.list
Mock.mock('/login', 'post', (options) => {
  login.userName = JSON.parse(options.body).data.userName
  login.passWord = JSON.parse(options.body).data.passWord
  return login
})
Mock.mock('/getData', patients)
Mock.mock('/addData', 'post', (options) => {
  var addData = JSON.parse(options.body)
  addData.id = Random.id()
  newList.unshift(addData)
  return newList
})

Mock.mock('/user', newList)
Mock.mock('/data', require('./tables.json'))
